<template>
  <rx-dialog @handOk="onOk" @cancel="cancel">
    <a-form style="height: 100%;">
      <a-row>
        <a-col :span="24">
          <a-form-item :label-col="labelCol1" :wrapper-col="wrapperCol1">
              {{i18n('btnScript.desc','说明：运行脚本配置...')}}
            dao.execute("{{i18n('btnScript.sourceAlias','数据源别名')}}","update w_zhucong set F_NAME='123' where ID_='${rows[0].ID_}'");
          </a-form-item>
        </a-col>
      </a-row>
      <a-row>
        <a-col :span="24">
          <a-form-item :label-col="labelCol1" :wrapper-col="wrapperCol1" :label="i18n('btnScript.appendField','插入脚本字段')">
            <a-select :options="fieldDatas" @change="appendField" style="width: 50%;"></a-select>
<!--            <a-button @click="insertScript">{{i18n('btnScript.insertScript','插入脚本')}}</a-button>-->
            <a-button @click="selectDataSource">{{i18n('btnScript.sourceAlias','选择数据源')}}</a-button>
          </a-form-item>
        </a-col>
      </a-row>
      <a-row>
        <a-col :span="24">
          <a-form-item :label-col="labelCol1" :wrapper-col="wrapperCol1">
            <rx-monaco-editor
              ref="scriptCode"
              v-model="serverHandleScript"
              language="java"
              style="height:300px;"
            >
            </rx-monaco-editor>
          </a-form-item>
        </a-col>
      </a-row>
    </a-form>
  </rx-dialog>
</template>

<script>
  import {Util,RxDialog,Dialog,RxMonacoEditor,JsConstant} from "@lowcode/jpaas-common-lib";
  import AppName from "@/assets/js/AppName.js";

  export default {
    name: "FormBoListBtnServerScript",
    mixins: [AppName],
    components: {
      RxDialog,
      RxMonacoEditor
    },
    props: ["row", "fieldDatas", "layerid", "destroy"],
    data(){
      return {
        labelCol: { span:6 },
        wrapperCol: { span:18 },
        labelCol1: { span:3 },
        wrapperCol1: { span:19 },
        serverHandleScript:""
      }
    },
    computed:{
      scriptCode(){
        return this.$refs.scriptCode;
      },
    },
    created() {
      this.setData();
    },
    methods:{
      i18n(name,text,key){
          return this.$ti18(name,text,"formBoList",key);
      },
      onOk(){
        Util.closeWindow(this,"ok");
      },
      cancel(){
        Util.closeWindow(this,"cancel");
      },
      setData(){
        this.serverHandleScript=this.row.config.serverHandleScript;
      },
      getData(){
        return this.serverHandleScript;
      },
      appendField(value){
        this.appendScript('${'+value+'}');
      },
      appendScript(text){
        this.scriptCode.insertContent(text);
      },
      insertScript(){

      },
      selectDataSource(){
        Dialog.openDataSourceDialog({
          curVm: this, widthHeight: ['1200px', '600px'],
          data:{appName: this.serviceName}
        }, function (self, data) {
          self.appendScript('"'+data.alias+'"');
        })
      }
    }
  }
</script>

<style scoped>

</style>